<?php

if (!MEMBER)
    common::accessdenied();
$owner = profile::photos(array('owner' => true, 'ID' => PARAMS));
$data->settings = account::settings($owner);
if (POST) {
    switch (PARAMS) {
        case 'delete':
            profile::photo(array('accountID' => UID, 'ID' => $_POST['photoID']), 'delete');
            break;
        case 'comment':
            if (!$data->settings->photos || $data->settings->photos->comment)
                profile::comment(array('senderID' => UID, 'itemID' => $_POST['PID'], 'comment' => $_POST['comment']));
            break;
    }
} else {
    if (PARAMS) {
        $data->photo = profile::photos(array('photo' => true, 'ID' => PARAMS));
        $data->postie->comments = @array_reverse(comment::thread(array('app' => 'profile', 'itemID' => PARAMS)));
    }

    $data->TITLE = $data->photo->caption ? $data->photo->caption : _('Content not found');
    $data->DESCRIPTION = $data->photo->caption ? _('Photos.') : _('This content is currently unavailable');
    $data->WIDGETS = 'postie';
}
?>